<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        /** 1
        * 功能：传入保存数字的数组，返回数组中的最大值对应的下标
        * 形参：数组
        * 返回值：有，返回数组中的最大值对应的下标
        */
        let arr = [12, 3, 23, 5, 22, 9]
        function maxIndex(arr) {
            let max = arr[0]
            console.log(arr)
            for (let i of arr.keys()) {
                if (arr[i] > max) {
                    max = arr[i]
                }
                if (max == arr[i]) {

                    return i
                }
            }

        }
        let re = maxIndex(arr)
        console.log(re)



    </script>
</body>

</html>